import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class OffstageDemo extends StatefulWidget{
  @override
  State<StatefulWidget> createState() =>OffstageState();
}
class OffstageState extends State<OffstageDemo>{
  bool isOff=false;
  String showText='hide';
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar:  AppBar(
        title: Text('Offstage'),
        centerTitle: true,
      ),
      body: Container(
        margin: EdgeInsets.only(top: 50),
        child: Offstage(
          offstage: isOff,
          child: Text('Offstage组件'),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: (){
          setState(() {
            isOff=!isOff;
            if(isOff){
              showText='show';
            }else{
              showText='hide';
            }

          });
        },
        child: Text(showText),
      ),
    );

  }

}